package com.demo.juc.three;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2022/11/18 16:15
 * @Version: 1.0
 */
public class Demo1 {

    static Lock lock = new ReentrantLock();

    public static void main(String[] args) {
        new Thread(()->{
            lock.lock();
            try {
                System.out.println("--外层");
                lock.lock();
                try {
                    System.out.println("--内层");
                }finally {

                    lock.unlock();
                }
            }finally {
                lock.unlock();
            }
        },"t1").start();

        new Thread(()->{
            lock.lock();
            try {
                System.out.println(Thread.currentThread().getName()+"\t"+"----调用开始");
            }finally {
                lock.unlock();
            }
        },"t2").start();
    }
}
